/** \file bfin-registers.h
 *
 * Contains the GDB internal register map used to communicate registers
 * between the GDB (client) and rproxy (debugging server).
 *
 * The register token numbers are directly encoded by register number and
 * group code so that the appropriate opcodes can be built easily.
 *
 * UGLY: There are gaps in the enumeration, which doesn't make the
 * registermap look contiguous when using 'info register' in GDB...
 *
 * Important: Make sure GDB includes the same file. Make also sure, that
 * REGISTER_NAMES (tm-bfin.h) match the bfin_registers{ } enumeration.
 *
 * TODO: Move this file to the GDB bfin distribution or use a translation
 * table on the rproxy side.
 *
 * (c) 11/2004 Martin Strubel <hackfin@section5.ch>
 *
 * $Id: bfin-registers.h 75 2005-11-11 09:12:34Z jiez $
 *
 */


#ifndef BFIN_REGISTER_DEFINITIONS_HEADER
#define BFIN_REGISTER_DEFINITIONS_HEADER

/* Stolen from binutils, since we don't want to include all the binutils
 * blurb..
 * Slightly modified, did some more compact encoding and added 'virtual'
 * registers. These are non-core registers which we would still like to see
 * via GDB..
 */

#define GROUP(x)    ((x >> 3) & 7)

#define T_REG_R       0x00
#define T_REG_P       (1 << 3)
#define T_REG_I       (2 << 3)
#define T_REG_M      ((2 << 3) + 4)
#define T_REG_B       (3 << 3)
#define T_REG_L      ((3 << 3) + 4)
#define T_REG_A       (4 << 3)
#define T_REG_LP      (6 << 3)
#define T_REG_X       (7 << 3)
#define T_NOGROUP     (8 << 3)   // all registers above this value don't
                                 // belong to a core register group


enum bfin_registers {
	REG_R0    = T_REG_R, REG_R1, REG_R2, REG_R3, REG_R4, REG_R5, REG_R6, REG_R7, 
	REG_P0    = T_REG_P, REG_P1, REG_P2, REG_P3, REG_P4, REG_P5, REG_SP, REG_FP,
	REG_I0    = T_REG_I, REG_I1, REG_I2, REG_I3,
	REG_M0    = T_REG_M, REG_M1, REG_M2, REG_M3, 
	REG_B0    = T_REG_B, REG_B1, REG_B2, REG_B3,
	REG_L0    = T_REG_L, REG_L1, REG_L2, REG_L3, 
	REG_A0x   = T_REG_A, REG_A0w, REG_A1x, REG_A1w,
	REG_ASTAT = T_REG_A + 6, REG_RETS,

	REG_LC0   = T_REG_LP, REG_LT0, REG_LB0,  REG_LC1, REG_LT1, REG_LB1,
	                  REG_CYCLES, REG_CYCLES2,

	REG_USP   = T_REG_X, REG_SEQSTAT, REG_SYSCFG,
	                  REG_RETI, REG_RETX, REG_RETN, REG_RETE, REG_EMUDAT,
};

// Some MMRs that can not be found in the standard headers`

#define MMR_IPEND        0xffe02108


#endif

